#!/bin/bash

## detect this dir
bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

## recognize user waue
if [ "$(whoami)" != "waue"  ]; then
   echo "you are not waue, exit!!"
   exit;
fi

## indicate path
PATH_etc=$bin/etc
PATH_hadoop=$bin/hadoop
PATH_work=$bin/ICAS_workspace
PATH_in=$bin/in
PATH_demo=$bin/www/demo

hadoop_bin=$PATH_hadoop/bin

## apt install java ssh .. etc
$hadoop_bin/stop-all.sh

## make more link
sudo rm /opt/hadoop
sudo rm /home/waue/ICAS_workspace
sudo rm /home/waue/in
sudo rm /var/www/icas
rm -rf $bin/ICAS_workspace/*
rm -rf $bin/hadoop/logs

## makesure the home bin 
sudo rm -rf /var/lib/hadoop

crontab -r

## remove all
read -p "delete all on /home/waue/ICAS ? [y=delete, n=not]:" ans
if [ "$ans" == "y" ] ;then
    rm -rf /home/waue/ICAS
fi

echo "ICAS-Remove finished"
